/*
 * searchTableModel.java
 *
 * Created on June 27, 2005, 3:36 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */
package com.bff.mpd.musicjukebox.lib;

import com.bff.mpd.utils.Utils;
import java.util.*;
import org.bff.javampd.objects.MPDSong;

/**
 *
 * @author Bill
 */
public class SearchTableModel extends SongTableModel {

    public static final int ARTIST = 0;
    public static final int ALBUM = 1;
    public static final int TITLE = 2;
    public static final int LENGTH = 3;
    public static final int TRACK = 4;
    public static final int YEAR = 5;
    public static final int GENRE = 6;
    private List<MPDSong> dataList = new ArrayList<MPDSong>();
    public final static String[] columnNames = {
        Utils.getMessage("TM_ARTIST"),
        Utils.getMessage("TM_ALBUM"),
        Utils.getMessage("TM_TITLE"),
        Utils.getMessage("TM_LENGTH"),
        Utils.getMessage("TM_TRACK"),
        Utils.getMessage("TM_YEAR"),
        Utils.getMessage("TM_GENRE")
    };

    /** Creates a new instance of ArtistTableModel */
    public SearchTableModel() {
    }

    public SearchTableModel(java.util.Collection songs) {
        dataList = new ArrayList(songs);
    }

    @Override
    public int getRowCount() {
        return (dataList.size());
    }

    @Override
    public Object getValueAt(int row, int col) {
        MPDSong song = (MPDSong) dataList.get(row);
        switch (col) {
            case ARTIST:
                return (song.getArtist());
            case ALBUM:
                return (song.getAlbum());
            case TITLE:
                return (song.getTitle());
            case LENGTH:
                return (song.getLength());
            case TRACK:
                return (song.getTrack());
            case YEAR:
                return (song.getYear());
            case GENRE:
                return (song.getGenre());
            default:
                return null;
        }
    }

    @Override
    public int getColumnCount() {
        return (columnNames.length);
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public MPDSong getSong(int row) {
        return ((MPDSong) dataList.get(row));
    }

    @Override
    public int getArtistColumnIndex() {
        return (ARTIST);
    }

    @Override
    public int getAlbumColumnIndex() {
        return (ALBUM);
    }

    @Override
    public int getTitleColumnIndex() {
        return (TITLE);
    }

    @Override
    public int getLengthColumnIndex() {
        return (LENGTH);
    }

    @Override
    public int getTrackColumnIndex() {
        return (TRACK);
    }

    @Override
    public int getYearColumnIndex() {
        return (YEAR);
    }

    @Override
    public int getGenreColumnIndex() {
        return (GENRE);
    }

    @Override
    public int getSortColumn() {
        return ARTIST;
    }
}
